Ext.define('Admin.view.leave.LeaveAddForm', {
    extend: 'Ext.form.Panel',
    alias: 'widget.leave-add-form',
    requires: [
        'Ext.button.Button',
        'Ext.form.field.*'
        //'Ext.form.field.File',
        //'Ext.form.field.Date',
        //'Ext.form.field.ComboBox',
        //'Ext.form.field.HtmlEditor'
    ],
    controller: 'leave',
    bodyPadding: 10,
    bodyBorder: true,


    defaults: {
        anchor: '100%'
    },
    fieldDefaults: {
        labelAlign: 'left',
        msgTarget: 'none',
        invalidCls: '',//unset the invalidCls so individual fields do not get styled as invalid
        allowBlank: false
    },

    items: [{
        xtype: 'textfield',
        name: 'userId',
        fieldLabel: '请假人',
        value: fullName,
        readOnly: true
    }, {
        xtype: 'combobox',
        name: 'leaveType',
        fieldLabel: '请假类型',
        store: Ext.create('Ext.data.Store', {
            fields: ['value', 'name'],
            data: [
                { "value": "A", "name": "带薪假期" },
                { "value": "B", "name": "无薪假期" },
                { "value": "C", "name": "病假" }
            ]
        }),
        queryMode: 'local',
        displayField: 'name',
        valueField: 'name'
    }, {
        id: 'leaveStartTime',
        xtype: 'datefield',
        fieldLabel: '请假开始时间',
        format: 'Y/m/d H:i:s',
        name: 'startTime',
        //,id: 'startdt',
        //vtype: 'daterange',
        //endDateField: 'enddt' // id of the end date field
        listeners: {
            change: function () {
                Ext.getCmp('leaveEndTime').setMinValue(this.value);
            }
        }
    }, {
        id: 'leaveEndTime',
        xtype: 'datefield',
        fieldLabel: '请假结束时间',
        format: 'Y/m/d H:i:s',
        name: 'endTime'
        //,id: 'enddt',
        //vtype: 'daterange',
        //startDateField: 'startdt' // id of the start date field
    }
        , {
        xtype: 'textareafield',
        grow: true,
        name: 'reason',
        fieldLabel: '请假原因',
        anchor: '100%'
    }, {
        xtype: 'hidden',
        name: 'id'
    }],

    bbar: ['->', {
        xtype: 'button',
        ui: 'soft-green',
        text: '保存',
        handler: 'onClickAddFormSubmitButton'
    }, {
            xtype: 'button',
            ui: 'gray',
            text: '取消',
            handler: function (btn) {
                var win = btn.up('window');
                if (win) {
                    win.close();
                }
            }
        }, '->']


});